﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using DOAN.DO;
using DOAN.BL;

namespace DOAN
{
    public partial class DoiMK : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["Tendangnhap"] == null)
                    Response.Redirect("Dangnhap.aspx");
            }
        }



        protected void btn_Click(object sender, EventArgs e)
        {
            if (txtmk2.Text == txtmk3.Text)
            {
                string s = Session["Tendangnhap"].ToString();
                ThanhvienDO obj = new ThanhvienBL().Select(new ThanhvienDO { Tentaikhoan = s });
                if (obj.Matkhau == txtmk.Text)
                {
                    obj.Matkhau = txtmk2.Text;
                    int kq = new ThanhvienBL().Update(obj);
                    if (kq != 0)
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Có lỗi xảy ra, vui lòng thử lại!');", true);
                    }
                    else
                    {
                        Response.Write("<script>alert('Đổi thanh cong')</script>");
                        //Response.Redirect("Default.aspx");
                    }
                }
                else
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Mật khẩu cũ không đúng!');", true);
            }
            else
            {
                Label4.Text = "Hai Mật khẩu ko khớp";
            }

        }
    }
}
